package io.nanfeng.gaia.exception.compiler


import org.junit.jupiter.api.Test


internal class ExceptionSymbolProcessorTest {
    interface ICodeWithMessage {
        val code: Int
        val message: String?
    }

    class CodeException(
        override val code: Int,
        override val message: String? = null,
        override val cause: Throwable? = null
    ) : RuntimeException(), ICodeWithMessage

    fun ICodeWithMessage.throws(throwable: Throwable? = null, vararg args: Any?): Nothing {
        throw CodeException(this.code, this.message?.format(args), throwable)
    }

    sealed class TestException(override val code: Int, override val message: String) : ICodeWithMessage, Exception() {

        object A1 : TestException(1, "dsaas")

        object A2 : TestException(2, "vve")
    }

    @Test
    fun process() {
        throw TestException.A2
    }
}